const WebSocket = require('ws');
const https = require('https'); // 新增引入https模块
// 创建忽略证书验证的Agent
const insecureAgent = new https.Agent({
  rejectUnauthorized: false // 禁用证书验证
});

const ws = new WebSocket('wss://localhost:3000', {
  agent: insecureAgent // 添加agent配置
});

ws.on('open', function open() {
  console.log('[CLIENT]: open')
  ws.send('something');
});

ws.on('close', function close(){
  console.log('[CLIENT]: close');
});
ws.on('message', function incoming(data) {
  console.log('[CLIENT]: Received:',data);
});
ws.on('ping', function(){
  console.log('[CLIENT]: ping')
})
